/*
 * @(#) WorkerServiceImpl.java Sep 10, 2011
 *
 * Copyright (c) 2011, Strong Technology. All Rights Reserved.
 * Strong Technology. CONFIDENTIAL
 */
package cn.strong.gweva.system.business.service.impl;

import java.util.Date;

import cn.strong.gweva.common.business.entity.PagerEntity;
import cn.strong.gweva.common.business.entity.db.JxkhWorkerEntity;
import cn.strong.gweva.common.business.service.impl.AbstractServiceImpl;
import cn.strong.gweva.common.util.Constants;
import cn.strong.gweva.common.util.Constants4Method;
import cn.strong.gweva.system.business.entity.WorkerEntity;
import cn.strong.gweva.system.business.entity.WorkerSearchEntity;
import cn.strong.gweva.system.business.service.WorkerService;


/**
 * 工作人员管理service实现类.
 * 
 * @author jincong
 * @version 1.0
 * @since Sep 10, 2011
 */
public class WorkerServiceImpl extends AbstractServiceImpl implements WorkerService
{

	/**
	 * 新增工作人员.
	 * 
	 * @param jxkhWorkerEntity 工作人员信息
	 * @throws Exception 异常
	 */
	public void insert(JxkhWorkerEntity jxkhWorkerEntity) throws Exception
	{
		jxkhWorkerEntity.setUpdateTime(new Date());
		jxkhWorkerEntity.setDelFlag(Constants.DEL_FLAG_NO);
		this.getCommonDao().insert(Constants4Method.SYSTEM_WORKER_INSERT_JXKH_WORKER,
				jxkhWorkerEntity);
	}

	/**
	 * 更新工作人员.
	 * 
	 * @param jxkhWorkerEntity 工作人员信息
	 * @throws Exception 异常
	 */
	public void update(JxkhWorkerEntity jxkhWorkerEntity) throws Exception
	{
		jxkhWorkerEntity.setUpdateTime(new Date());
		this.getCommonDao().update(Constants4Method.SYSTEM_WORKER_UPDATE_JXKH_WORKER,
				jxkhWorkerEntity);
	}

	/**
	 * 删除工作人员.
	 * 
	 * @param jxkhWorkerEntity 工作人员信息
	 * @throws Exception 异常
	 */
	public void delete(JxkhWorkerEntity jxkhWorkerEntity) throws Exception
	{
		this.getCommonDao().delete(Constants4Method.SYSTEM_WORKER_DELETE_JXKH_WORKER,
				jxkhWorkerEntity);
	}

	/**
	 * 逻辑删除工作人员.
	 * 
	 * @param jxkhWorkerEntity 工作人员信息
	 * @throws Exception 异常
	 */
	public void logicDeleteWorker(JxkhWorkerEntity jxkhWorkerEntity) throws Exception
	{
		jxkhWorkerEntity.setDelFlag(Constants.DEL_FLAG_YES);
		this.getCommonDao().update(Constants4Method.SYSTEM_WORKER_LOGIC_DELETE_JXKH_WORKER,
				jxkhWorkerEntity);
	}

	/**
	 * 工作人员分页查询.
	 * 
	 * @param pagerEntity
	 * @param workerSearchEntity
	 * @return 工作人员分页信息
	 * @throws Exception 异常
	 */
	public PagerEntity searchWorkerPage(PagerEntity pagerEntity,
			WorkerSearchEntity workerSearchEntity) throws Exception
	{
		return this.getCommonDao().searchPager(pagerEntity,
				Constants4Method.SYSTEM_WORKER_SEARCH_JXKH_WORKER_LIST, workerSearchEntity);
	}

	/**
	 * 根据工作人员编号查询工作人员信息.
	 * 
	 * @param jxkhWorkerEntity 查询条件
	 * @return 工作人员信息
	 * @throws Exception 异常
	 */
	public WorkerEntity searchWorkerById(JxkhWorkerEntity jxkhWorkerEntity) throws Exception
	{
		return (WorkerEntity)this.getCommonDao().searchObj(
				Constants4Method.SYSTEM_WORKER_SEARCH_JXKH_WORKER_BY_ID, jxkhWorkerEntity);
	}

	
	/**
	 * 校验工作人员编号的存在性。
	 * 
	 * @param workerCode 工作人员编号
	 * @return 存在的件数
	 * @throws Exception
	 */
	public int checkWorkerCodeExist(String workerCode) throws Exception
	{
		return this.getCommonDao().searchCount(
				Constants4Method.SYSTEM_WORKER_CHECK_WORKER_CODE_EXIST, workerCode);
	}
}
